#ifndef MOTOR_H
#define MOTOR_H
#define X_Motor_Tim         TIM1
#define X_Motor_TimCh1      GPIO_Pin_9
#define X_Motor_TimCh2      GPIO_Pin_11
#define X_Motor_TimGPIO     GPIOE
#define X_Motor_PLUSE       GPIO_Pin_12
#define X_Motor_PLUSEGPIO   GPIOE

#define X_Motor_DIR         GPIO_Pin_15
#define X_Motor_DIRGPIO     GPIOD

#define Y_Motor_Tim         TIM4
#define Y_Motor_TimCh1      GPIO_Pin_6
#define Y_Motor_TimCh2      GPIO_Pin_7
#define Y_Motor_TimGPIO     GPIOB
#define Y_Motor_PLUSE       GPIO_Pin_9
#define Y_Motor_PLUSEGPIO   GPIOB

#define Y_Motor_DIR         GPIO_Pin_6
#define Y_Motor_DIRGPIO     GPIOC


#define SET_X_PLUSE       X_Motor_PLUSEGPIO->BSRR = X_Motor_PLUSE;X_Motor_PLUSEGPIO->BRR = X_Motor_PLUSE//GPIO_SetBits(GPIOD, GPIO_Pin_14);GPIO_ResetBits(GPIOD, GPIO_Pin_14)
#define SET_Y_PLUSE       Y_Motor_PLUSEGPIO->BSRR = Y_Motor_PLUSE;Y_Motor_PLUSEGPIO->BRR = Y_Motor_PLUSE
#define SET_Z_PLUSE
#define X_Positive        X_Motor_DIRGPIO->BSRR = X_Motor_DIR
#define X_Negative        X_Motor_DIRGPIO->BRR = X_Motor_DIR
#define Y_Positive        Y_Motor_DIRGPIO->BSRR = Y_Motor_DIR
#define Y_Negative        Y_Motor_DIRGPIO->BRR = Y_Motor_DIR
#define Z_Positive        
#define Z_Negative        
#define LineSection   5
typedef struct{  
  int XPos;
  int YPos;
  int ZPos;
  int StartSpeed;
  int MaxSpeed;
  int StopSpeed;
  
  int LineLen[LineSection];  
  char XStep;
  char YStep;
  char ZStep;
  int Xe;
  int Ye;
  int Ze;
  double K;
}Line_Par;


extern volatile Line_Par LinePar[256];
extern volatile unsigned char LineParIn;
extern volatile unsigned char LineParOut;

extern volatile int XRecvPos;
extern volatile int YRecvPos;
extern volatile int ZRecvPos;

extern volatile int StartSpeed;
extern volatile int MaxSpeed;
extern volatile int StopSpeed;
extern volatile double AccAccSpeed; 

extern volatile int RecvStartSpeed;
extern volatile int RecvMaxSpeed;
extern volatile int RecvStopSpeed;

void X_Motor_Init(void);
void Y_Motor_Init(void);
void Timer2_Init(void);
void Set_XYLineLen(void);
#endif
